//
//  YAStatusForwardCell.swift
//  KeepCliming
//
//  Created by 鱼龙之梦 on 15/9/7.
//  Copyright © 2015年 panyanzhi. All rights reserved.
//

import UIKit

class YAStatusForwardCell: YAStatusCell {
 //转发文字
    private lazy var forworadLabel: FFLabel = FFLabel(title: "#转发微博#", color: UIColor.darkGrayColor(), fontSize: 14, layoutWidth: UIScreenWidth - 2 * YAStatusCellMargin)
    //背景图片
    private lazy var backButton:UIButton = {
        let button = UIButton()
        button.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        return button
    }()
    //问题：为什么要重写这个属性：重写后父类的依然会被调用  增加个性字段
    override var statusVM:YAStatusVM?{
        didSet{
            let forwardText = statusVM?.forwordText ?? ""
            forworadLabel.attributedText = YAEmoticonViewModel.sharedEVM.emoticonText(forwardText, font: forworadLabel.font)
        }
    }
         override func setupUI(){
      super.setupUI()
      contentView.insertSubview(backButton, belowSubview: pictureView)
      contentView.insertSubview(forworadLabel, aboveSubview: backButton)
        
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil,offset:CGPoint(x: -YAStatusCellMargin, y: YAStatusCellMargin))
        
        backButton.ff_AlignVertical(type: ff_AlignType.TopCenter, referView: bottomView, size: nil)
        
        forworadLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: YAStatusCellMargin, y: YAStatusCellMargin))
        
        //配图视图
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forworadLabel, size: CGSize(width: 290, height: 290),offset:CGPoint(x: 0, y: YAStatusCellMargin))
        picHeightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        picWidthCons  = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        picTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
        forworadLabel.labelDelegate = self
    }
}
